<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品管理</title>
    <link href="/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="/layui/css/layui.css">
    <style type="text/css">
        /* 去除所有的页边距 */
        *{
            margin:0px;
            padding:0px;
        }

        body {
            background-color: #DFF0D8;
        }

        #titleTab{
        }

        #goodsType{
            display: flex;
            justify-content:flex-start;
            align-items:flex-start;
            /*可以改么*/height: 50px;
            margin: 0;
        }


        .bt{
            background-color: #287d6b;
        }
        .container {
        }
        .panel {
            background-size: auto, 100%;
            background-position: center;
            background-repeat: no-repeat;
            border-radius: 50px;
            color: #fff;
            flex: 0.5;
            cursor: pointer;
            /*注意*/height: 50vh;
            position: relative;
            margin: 10px;
            transition: flex 0.7s cubic-bezier(0.05, 0.6, 0.4, 0.9);
        }
        .panel h3 {
            font-size: 24px;
            opacity: 0;
            position: absolute;
            bottom: 20px;
            left: 20px;
            margin: 0;
            transition: opacity 0s ease-in 0s;
        }
        .panel.active {
            flex: 5;
        }
        .panel.active h3 {
            opacity: 1;
            transition: opacity 0.3s ease-in 0.4s;
        }

        </style>
</head>

<body>
<div class="container" style=" margin-top:10px;">
    <!--导航栏部分-->
    <div class="row clearfix" id="titleTab">
        <div class="col-md-12 column">
            <ul class="layui-nav layui-bg-green" lay-filter="">
                <!--class="layui-this" 使得按钮处于选中-->
                <li class="layui-nav-item"><a href="/pages/首页.html">首页</a></li>
                <li class="layui-nav-item"><a href="/pages/客房管理.html">客房管理</a></li>
                <li class="layui-nav-item"><a href="/pages/会员管理.html">会员管理</a></li>
                <li class="layui-nav-item layui-this"><a href="">商品管理</a></li>
                <li class="layui-nav-item"><a href="/pages/员工管理.html">员工管理</a></li>
                <li class="layui-nav-item"><a href="/pages/系统日志.html">系统日志</a></li>

            </ul>
        </div>
    </div>


    <!--商品类别部分-->
    <div class="col-md-6 column">
        <!--商品导航栏-->
        <div class="row clearfix form-inline form-group" style="margin-top: 15px">
            <button type="button" class="btn btn-primary btn-lg" style="text-shadow: black 5px 3px 3px;">
                <span class="glyphicon glyphicon-tags"></span>    商品类型
            </button>
            <div class="col-md-1 column"></div>
            <input type="text" id="searchForGoodsTypeText" class="form-control" placeholder="输入编号或类型名称" style="margin-left: 35px">
            <button class="btn btn-default" type="button" onclick="searchForGoodsType()">查找</button>
            <button class="btn btn-default" type="button" onclick="showNewGoodsTypeModal()">添加</button>
        </div>

        <!--商品展示类别-->
        <div class="row clearfix" id="goodsType">
            <div class="panel" style="background-image: url(../layui/img/日用品.jpg);">
                <h3>洗涤日用</h3>
            </div>
            <div class="panel" style="background-image: url(../layui/img/家具.jpg);">
                <h3>文体办公</h3>
            </div>
            <div class="panel" style="background-image: url(../layui/img/美酒.jpg);">
                <h3>饮品烟酒</h3>
            </div>
            <div class="panel" style="background-image: url(../layui/img/美食.jpg);">
                <h3>日配主食</h3>
            </div>
            <div class="panel" style="background-image: url(../layui/img/健身.jpg);">
                <h3>休闲娱乐</h3>
            </div>
        </div>

        <!--更多商品-->
        <div class="row clearfix" style="margin-top: 45vh">
            <table class="layui-table table-hover table-striped table-condensed" lay-skin="line" lay-size="sm"
                   style='text-align: center;margin-top:14px;background-color: #f7f7f7'>
                <thead>
                <tr>
                    <td>商品类型编号</td>
                    <td>商品类型</td>
                    <td>操作</td>
                </tr>
                </thead>
                <tbody id="tbody_type">
                </tbody>
            </table>
        </div>
    </div>

    <!--商品信息-->
    <div class="col-md-6">
        <!--商品信息导航栏-->
        <div class="row clearfix form-inline form-group" style="margin-top: 15px">
            <button type="button" class="btn btn-primary btn-lg" style="text-shadow: black 5px 3px 3px;">
                <span class="glyphicon glyphicon-shopping-cart"></span>    商品表单
            </button>
            <div class="col-md-1 column"></div>
            <input type="text"
                   id="searchForGoodsText"
                   class="form-control"
                   placeholder="输入编号或商品名称"
                   style="margin-left: 35px">
            <button class="btn btn-default" type="button" onclick="searchForGoods()">查找</button>
            <button class="btn btn-default" type="button" onclick="showNewGoodsModal()">添加</button>
        </div>
        <!--商品表格-->
        <div class="row clearfix">
            <table class="layui-table table-hover table-striped table-condensed" lay-skin="line" lay-size="sm"
                   style='text-align: center;margin-top:14px;background-color: #f7f7f7'>
                <thead>
                <tr>
                    <td>商品编号</td>
                    <td>商品名称</td>
                    <td>单价</td>
                    <td>库存数量</td>
                    <td>商品类型</td>
                    <td>操作</td>
                </tr>
                </thead>
                <tbody id="tbody">
                </tbody>
            </table>
        </div>
    </div>

</div>

<!-- 新建商品类别的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="newGoodsTypeModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">新建商品类别</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="newGoodsType_id">
                <form class="form-horizontal">
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">商品类型:</label>
                        <div class="col-lg-8">
                            <input type="text" name="newGoodsType_name" id="newGoodsType_name" class="form-control"
                                   placeholder="请输入商品类型名称">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doneNewGoodsType()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 新建商品单个商品信息的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="newGoodsModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">添加商品</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="newGoods_id">
                <form class="form-horizontal">
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">商品名称:</label>
                        <div class="col-lg-8">
                            <input type="text" name="newGoodsName" id="newGoodsName" class="form-control"
                                   placeholder="请输入商品名称">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">商品价格:</label>
                        <div class="col-lg-8">
                            <input type="text" name="newPrice" id="newPrice" class="form-control"
                                   placeholder="请输入商品价格">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">商品件目:</label>
                        <div class="col-lg-8">
                            <input type="text" name="newNumber" id="newNumber" class="form-control"
                                   placeholder="请输入商品件数">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">商品种类:</label>
                        <div class="col-lg-8">
                            <select name="newGoodsType" id="newGoodsType" class="form-control">
                                <!--这里之后要看看能不能调用数据库中的表填充选项-->
                                <option value="日用品">日用品</option>
                                <option value="健身">健身</option>
                                <option value="美食">美食</option>
                                <option value="美酒">美酒</option>
                                <option value="家具">家具</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doneNewGoods()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 删除商品类别的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="delGoodsTypeModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">删除提醒</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="delGoodsType_id">
                <div class="form-group">
                    <label>要删除的商品类别：</label>
                    <p id="delGoodsType_msg"></p>
                </div>
                <p>是否要删除该商品类别？</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doDeleteGoodsType()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 删除商品信息的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="delGoodsModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">删除提醒</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="delGoods_id">
                <div class="form-group">
                    <label>要删除的商品名称：</label>
                    <p id="delGoods_name">商品名称：</p>
                    <label>要删除的商品属于种类：</label>
                    <p id="delGoods_type">商品类别：</p>
                </div>
                <p>是否要删除该商品？</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doDeleteGoods()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 修改商品类别信息的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="editGoodsTypeModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">修改商品类别信息</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="editGoodsType_id">
                <form class="form-horizontal">
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">商品类别:</label>
                        <div class="col-lg-8">
                            <input type="text" name="editGoodsType_name" id="editGoodsType_name" class="form-control"
                                   placeholder="请输入修改的商品类别">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doneEditGoodsType()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 修改商品信息的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="editGoodsModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">修改商品信息</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="editGoods_id">
                <form class="form-horizontal">
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">商品名称:</label>
                        <div class="col-lg-8">
                            <input type="text" name="Goods_name" id="Goods_name" class="form-control"
                                   placeholder="请输入商品名称">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">商品价格:</label>
                        <div class="col-lg-8">
                            <input type="text" name="Goods_price" id="Goods_price" class="form-control"
                                   placeholder="请输入商品价格">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">商品数量:</label>
                        <div class="col-lg-8">
                            <input type="text" name="Goods_number" id="Goods_number" class="form-control"
                                   placeholder="请输入商品数量">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">商品类别:</label>
                        <div class="col-lg-8">
                            <select name="editGoodsType" id="editGoodsType" class="form-control">
                                <!--这里之后要看看能不能调用数据库中的表填充选项-->
                                <option value="日用品">日用品</option>
                                <option value="健身">健身</option>
                                <option value="美食">美食</option>
                                <option value="美酒">美酒</option>
                                <option value="家具">家具</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doneEditGoods()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 查询商品类型信息的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="searchForGoodsTypeModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">查询结果</h4>
            </div>
            <div class="modal-body">
                <div class="row clearfix">
                    <table class="layui-table table-hover table-striped table-condensed" lay-skin="line" lay-size="sm"
                           style='text-align: center;margin-top:14px;background-color: #f7f7f7'>
                        <thead>
                        <tr>
                            <td>商品类型编号</td>
                            <td>商品类型</td>
                        </tr>
                        </thead>
                        <tbody id="goodsTypeTable">
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 查询商品信息的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="searchForGoodsModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">查询结果</h4>
            </div>
            <div class="modal-body">
                <div class="row clearfix">
                    <table class="layui-table table-hover table-striped table-condensed" lay-skin="line" lay-size="sm"
                           style='text-align: center;margin-top:14px;background-color: #f7f7f7'>
                        <thead>
                        <tr>
                            <td>商品编号</td>
                            <td>商品名称</td>
                            <td>价格</td>
                            <td>数量</td>
                            <td>商品类型</td>
                        </tr>
                        </thead>
                        <tbody id="goodsTable">
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>

<script src="/jquery/jquery-3.4.1.js"></script>
<script src="/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!--导航栏脚本-->
<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;

        //…
    });
</script>
<!--活动页面脚本-->
<script>
    const panels = document.querySelectorAll(".panel");
    panels.forEach((panel) => {
        panel.addEventListener("click", () => {
            removeClass();
            panel.classList.add("active");
        });
        function removeClass() {
            panels.forEach((panel) => {
                panel.classList.remove("active");
            });
        }
    });
</script>
<!--数据库脚本-->
<script type="text/javascript">
    /*初始化页面数据*/
    jQuery(function () {
        // /goods_all请求的地址
        jQuery.post("/goods_all",function (rst) {
            var body="";
            for (var i=0;i<rst.length;i++){
                var json=rst[i];//{"id":1,"goods_name":"百岁山","goods_price":"3","goods_number":"50","goods_type"="饮料"}
                body+="<tr>";
                body+="<td>"+json.id+"</td>";
                body+="<td>"+json.goods_name+"</td>";
                body+="<td>"+json.goods_price+"</td>";
                body+="<td>"+json.goods_number+"</td>";
                body+="<td>"+json.goods_type+"</td>";
                body+="<td>";
                body+="<a href='#' onclick='showDelGoodsModal(\""+json.id+"\",\""+json.goods_name+"\",\""+json.goods_type+"\")'>删除</a>&nbsp;&nbsp;";
                body+="<a href='#' onclick='showEditGoodsModal(" +
                    "\""+json.id+"\"," +
                    "\""+json.goods_name+"\"," +
                    "\""+json.goods_price+"\"," +
                    "\""+json.goods_number+"\"," +
                    "\""+json.goods_type+"\")'>修改</a>";
                body+="</td>"
                body+="</tr>";
            }
            jQuery("#tbody").html(body);
        },"json");

        jQuery.post("/goodsType_all",function(rst){//处理响应的结果
            var body="";
            for(var i=0;i<rst.length;i++)
            {
                var json=rst[i];//{"id":1,"type_name":"饮料"}
                body+="<tr>";
                body+="<td>"+json.id+"</td>";
                body+="<td>"+json.goodsType_name+"</td>";
                body+="<td>";
                body+="<a href='#' onclick='showDelGoodsTypeModal(\""+json.id+"\",\""+json.goodsType_name+"\")'>删除</a>&nbsp;&nbsp;";
                body+="<a href='#' onclick='showEditGoodsTypeModal(" +
                    "\""+json.id+"\"," +
                    "\""+json.goodsType_name+"\")'>修改</a>";
                body+="</td>"
                body+="</tr>";
            }
            jQuery("#tbody_type").html(body);
        },"json");//表示返回数据的格式

    })

    /*添加新商品种类*/
    function showNewGoodsTypeModal() {
        jQuery("#newGoodsTypeModal").modal("show");
    }
    function doneNewGoodsType() {
        jQuery("#newGoodsTypeModal").modal("hide");
        var type_name =jQuery("#newGoodsType_name").val();
        jQuery.post("/goodsType_save",{"name":type_name},function (rst) {
            alert(rst);
            if(rst=="添加成功")
            {
                location.reload();
            }
        })
    }

    <!--添加新商品-->
    function showNewGoodsModal() {
        /*从数据库中加载选择商品种类下拉框中的各项*/
        var strOptions = "";
        jQuery.post("/goodsType_all",function (rst) {
            for(var i=0;i<rst.length;i++)
            {
                var json=rst[i];//{"id":1,"type_name":"饮料"}
                strOptions += "<option value = '"+json.goodsType_name+"' >"+json.goodsType_name+"</option>";
            }
            document.getElementById("newGoodsType").innerHTML = strOptions;
        },"json")

        jQuery("#newGoodsModal").val();
        jQuery("#newGoodsName").val();
        jQuery("#newPrice").val();
        jQuery("#newNumber").val();
        jQuery("#newGoodsType").val();
        jQuery("#newGoodsModal").modal("show");
    }
    function doneNewGoods() {
        jQuery("#newGoodsModal").modal("hide");
        var goods_name =jQuery("#newGoodsName").val();
        var goods_price =jQuery("#newPrice").val();
        var goods_number =jQuery("#newNumber").val();
        var goods_type =jQuery("#newGoodsType").val();
        jQuery.post("/goods_save",{
            "name":goods_name,
            "price":goods_price,
            "number":goods_number,
            "type":goods_type},function (rst) {
            alert(rst);
            if(rst=="添加成功")
            {
                location.reload();
            }
        })
    }

    <!--修改商品种类-->
    function showEditGoodsTypeModal(id,type_name) {
        jQuery("#editGoodsType_id").val(id);
        jQuery("#editGoodsType_name").val(type_name);
        jQuery("#editGoodsTypeModal").modal("show");
    }
    function doneEditGoodsType() {
        jQuery("#editGoodsTypeModal").modal("hide");
        var id =jQuery("#editGoodsType_id").val();
        var type_name = jQuery("#editGoodsType_name").val();
        jQuery.post("/goodsType_edit",{
            "id":id,
            "name":type_name
        },function (rst) {
            alert(rst);
            if(rst=="修改成功")
            {
                location.reload();
            }
        })
    }
    <!--修改商品信息-->
    function showEditGoodsModal(id,goods_name,goods_price,goods_number,goods_type) {
        /*从数据库中加载选择商品种类下拉框中的各项*/
        var strOptions = "";
        jQuery.post("/goodsType_all",function (rst) {
            for(var i=0;i<rst.length;i++)
            {
                var json=rst[i];//{"id":1,"type_name":"饮料"}
                strOptions += "<option value = '"+json.goodsType_name+"' >"+json.goodsType_name+"</option>";
            }
            document.getElementById("editGoodsType").innerHTML = strOptions;
        },"json")
        jQuery("#editGoods_id").val(id);
        jQuery("#Goods_name").val(goods_name);
        jQuery("#Goods_price").val(goods_price);
        jQuery("#Goods_number").val(goods_number);
        /*这里可不可以用jQuery加载 2020.7.7：可以了*/
        jQuery("#editGoodsType").val(goods_type);
        jQuery("#editGoodsModal").modal("show");
    }
    function doneEditGoods() {
        jQuery("#editGoodsModal").modal("hide");
        var id =jQuery("#editGoods_id").val();
        var goods_name =jQuery("#Goods_name").val();
        var goods_price =jQuery("#Goods_price").val();
        var goods_number = jQuery("#Goods_number").val();
        /*这里可不可以用jQuery加载*/
        var goods_type=jQuery("#editGoodsType").val();
        jQuery.post("/goods_edit",{
            "id":id,
            "name":goods_name,
            "price":goods_price,
            "number":goods_number,
            "type":goods_type
        },function (rst) {
            alert(rst);
            if(rst=="修改成功")
            {
                location.reload();
            }
        })
    }
    <!--删除商品种类-->
    function showDelGoodsTypeModal(id,name) {
        jQuery("#delGoodsType_id").val(id);
        jQuery("#delGoodsType_msg").html(name);
        jQuery("#delGoodsTypeModal").modal("show");
    }
    function doDeleteGoodsType() {
        jQuery("#delGoodsTypeModal").modal("hide");
        var id = jQuery("#delGoodsType_id").val();
        jQuery.post("/goodsType_delete",{
            "id":id
        },function (rst) {
            alert(rst);
            if(rst=='删除成功')
            {
                //重新加载
                location.reload();
            }
        })
    }
    <!--删除商品信息-->
    function showDelGoodsModal(id,name,type) {
        jQuery("#delGoods_id").val(id);
        jQuery("#delGoods_name").html(name);
        jQuery("#delGoods_type").html(type);
        jQuery("#delGoodsModal").modal("show");
    }
    function doDeleteGoods() {
        jQuery("#delGoodsModal").modal("hide");
        var id = jQuery("#delGoods_id").val();
        jQuery.post("/goods_delete",{
            "id":id
        },function (rst) {
            alert(rst);
            if(rst=='删除成功')
            {
                //重新加载
                location.reload();
            }
        })
    }
    <!--得到种类信息，写成一个函数，返回若干个字符串给生成模态框时用-->

    <!--查询商品种类信息-->
    function searchForGoodsType() {
        var search = jQuery("#searchForGoodsTypeText").val();

        jQuery.post("/goodsType_findById", {
            "id":search
        }, function (rst) {
            var body="";

            var json = rst;
            var flag = json.goodsType_name;
            if(flag=="未查到"){
                alert("按照编号未查询到"+search);
            }else{
                body+="<tr>";
                body+="<td>"+json.id+"</td>";
                body+="<td>"+json.goodsType_name+"</td>";
                body+="</tr>";
                jQuery("#goodsTypeTable").html(body);
                jQuery("#searchForGoodsTypeModal").modal("show");
            }
        },"json")

        jQuery.post("/goodsType_findByName", {
            "name":search
        }, function (rst) {
            var body="";

            var json = rst;
            var flag = json.goodsType_name;
            if(flag=="未查到"){
                alert("按照名称未查询到"+search);
            }else{
                body+="<tr>";
                body+="<td>"+json.id+"</td>";
                body+="<td>"+json.goodsType_name+"</td>";
                body+="</tr>";
                jQuery("#goodsTypeTable").html(body);
                jQuery("#searchForGoodsTypeModal").modal("show");
            }
        },"json")

        /*if(jQuery("#searchForGoodsTypeModal").css('display')=="none"){
            alert("找不到"+search);
        }*/
    }
    <!--查询单个商品信息-->
    function searchForGoods() {
        var search = jQuery("#searchForGoodsText").val();

        jQuery.post("/goods_findById", {
            "id":search
        }, function (rst) {
            var body="";
            var json = rst;
            var flag = json.goods_name;
            if(flag=="未查到"){
                alert("按照编号未查询到"+search);
            }else{
                body+="<tr>";
                body+="<td>"+json.id+"</td>";
                body+="<td>"+json.goods_name+"</td>";
                body+="<td>"+json.goods_price+"</td>";
                body+="<td>"+json.goods_number+"</td>";
                body+="<td>"+json.goods_type+"</td>";
                body+="</tr>";
                jQuery("#goodsTable").html(body);
                jQuery("#searchForGoodsModal").modal("show");
            }
        },"json")

        jQuery.post("/goods_findByName", {
            "name":search
        }, function (rst) {
            var body="";

            var json = rst;
            var flag = json.goods_name;
            if(flag=="未查到"){
                alert("按照名称未查询到"+search);
            }else{
                body+="<tr>";
                body+="<td>"+json.id+"</td>";
                body+="<td>"+json.goods_name+"</td>";
                body+="<td>"+json.goods_price+"</td>";
                body+="<td>"+json.goods_number+"</td>";
                body+="<td>"+json.goods_type+"</td>";
                body+="</tr>";
                jQuery("#goodsTable").html(body);
                jQuery("#searchForGoodsModal").modal("show");
            }
        },"json")

        /*if(jQuery("#searchForGoodsTypeModal").css('display')=="none"){
            alert("找不到"+search);
        }*/
    }

</script>
</html>